package com.atguigu.pratice;

public class Gloves {
    public static void main(String[] args) {
        int[] left=new int[]{0,7,1,6};
        int[] right=new int[]{1,5,0,6};
        System.out.println(findMinimum(4,left,right));
    }
    //一次伟大尝试
    public static int findMinimum(int n,int[] left,int[] right){
        //记录最终答案
        int res=0;
        //左手套总数
        int leftSum=0;
        int leftMin=30;
        //右手套
        int rightSum=0;
        int rightMin=30;
        int tmp=0;
        for(int i=0;i<n;i++){
            if(left[i]*right[i]==0){
                tmp=tmp+left[i]+right[i];
            }else{
                leftSum+=left[i];
                leftMin=Math.min(left[i],leftMin);
                rightSum+=right[i];
                rightMin=Math.min(right[i],rightMin);
            }
        }
        int ret=Math.min(leftSum-leftMin+1,rightSum-rightMin+1);
        res=ret+tmp+1;
        return res;
    }
}
